package com.farmpost.server.controller;


import com.farmpost.server.pojo.RespBean;
import com.farmpost.server.pojo.UserBind;
import com.farmpost.server.service.IUserBindService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户绑定表 前端控制器
 * </p>
 *
 * @author king
 * @since 2022-04-03
 */

@RestController
@RequestMapping("/user-bind")
public class UserBindController {

    @Autowired
    private IUserBindService iUserBindService;

    @ApiOperation(value = "用户绑定信息插入")
    @PostMapping("/insertUserBind")
    public RespBean insertUserBind(@RequestBody UserBind userBind) {
        return iUserBindService.insertUserBind(userBind);
    }

    @ApiOperation(value = "用户绑定信息修改")
    @PutMapping("/updateUserBind")
    public RespBean updateUserBind(@RequestBody UserBind userBind) {
        return iUserBindService.updateUserBind(userBind);
    }

    @ApiOperation(value = "用户绑定信息查询")
    @GetMapping("/getUserBind")
    public UserBind getUserBind(@RequestParam Integer userId) {
        return iUserBindService.getUserBind(userId);
    }

    @ApiOperation(value = "用户绑定信息解绑")
    @DeleteMapping("/deleteUserBind")
    public RespBean deleteUserBind(@RequestParam UserBind userBind) {
        //解绑时前端把对应社交方式置为null
        return updateUserBind(userBind);
    }
}
